package com.yingxin.yxerp.module.permission.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yingxin.yxerp.module.permission.entity.AppPermission;
import com.yingxin.yxerp.module.permission.mapper.AppPermissionMapper;
import com.yingxin.yxerp.module.permission.service.IAppPermissionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * app功能权限 服务实现类
 * </p>
 *
 * @author matongtong
 * @since 2023-12-04
 */
@Service
public class AppPermissionServiceImpl extends ServiceImpl<AppPermissionMapper, AppPermission> implements IAppPermissionService {


    public AppPermissionMapper mapper() {
        return baseMapper;
    }

    /**
    * 创建
    *
    * @param entity
    *
    */
    @Transactional(rollbackFor = RuntimeException.class)
    @Override
    public void create(AppPermission entity) {
        save(entity);
    }

    @Override
    public List<AppPermission> listByParentId(String parentId) {
        QueryWrapper<AppPermission> qw = new QueryWrapper<>();
        qw.lambda().eq(AppPermission::getParentId, parentId);
        qw.lambda().orderByAsc(AppPermission::getId);
        return list(qw);
    }


}
